<template>
  <div class="app-container"  style="height: 100%;width: 100%;display: flex;align-items: center;justify-content: center" v-loading="viewLoading">
<!--    <el-button type="primary" @click="SSOLogin">测试登陆</el-button>-->
  </div>
</template>

<script>
import userManager from "@/utils/oidc";


import waves from '@/directive/waves'
import {oidcLogin} from "@/api/user";
import {setToken} from "@/utils/auth"; // waves directive
export default {
  name: 'oidc',
  directives: {waves},
  data() {
    return {
      viewLoading:true,
      ssoIdtoken:''
    }
  },

  mounted:function() {
    this.ssoIdtoken = this.getUrlparam('token')//自定义方法获取token信息
    if (this.ssoIdtoken && this.ssoIdtoken != null && this.ssoIdtoken != ''){
      // this.onssosignIn(this.ssoIdtoken)
      this.$store.commit('user/SET_TOKEN',this.ssoIdtoken)
      setToken(this.ssoIdtoken)
   console.log("token",this.ssoIdtoken)
         this.$router.push({ path: '/' })
      this.viewLoading = false
    }else{
      this.SSOLogin();
    }

  },
  methods:{
    getUrlparam(name) {
      return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ""])[1].replace(/\+/g, '%20')) || null
    },
    // onssosignIn(token) {
    //   console.log("这里进入登陆处理")
    //   oidcLogin({ id_token:token }).then(response => {
    //     const { data } = response
    //     console.log(data)
    //     this.$store.commit('user/SET_TOKEN', data.token)
    //     setToken(data.token)
    //     this.$router.push({ path: '/', query: this.otherQuery })
    //     this.viewLoading = false
    //   }).catch(error => {
    //     console.log(error)
    //
    //   })
    // },
    SSOLogin(){
      const url = 'https://login.microsoftonline.com/0ae51e19-07c8-4e4b-bb6d-648ee58410f4/oauth2/v2.0/authorize?response_type=id_token&response_mode=form_post&scope=openid&state=12345&nonce=678910&client_id=67a79331-1f76-4a77-976e-5e5dbbeb5432&redirect_uri=https://cngvm00100.apac.bosch.com:449/api/sso/idtoken';
      window.location.href=url;
    }
  }
}
</script>
<style scoped="scoped" type="scss">
.pagination-container {
  padding: 0px;
  padding-bottom: 16px;
}
.file-button-img-dir {
  background-position: 0px -50px;
}

.file-button-img-image {
  background-position: 0px -250px;
}

.file-button-img-music {
  background-position: 0px -350px;
}

.file-button-img-vedio {
  background-position: 0px -400px;
}

.file-button-img-txt {
  background-position: 0px -450px;
}

.file-button-img-pdf {
  background-position: 0px -500px;
}

.file-button-img-gw {
  background-position: 0px -550px;
}

.file-button-img-world {
  background-position: 0px -1500px;
}

.file-button-img-exe {
  background-position: 0px -900px;
}

.file-button-img-zip {
  background-position: 0px -1150px;
}

.file-button-img-ppt {
  background-position: 0px -1400px;
}

.file-button-img-excel {
  background-position: 0px -1450px;
}
.hoverbutton {
  width: 70px;
  height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  border-radius: 3px;
}

.hoverbutton:hover {
  border: 1px solid #999999;
}

.setcheckbox .el-checkbox {
  margin-bottom: 10px;
}

.searchform .el-form-item {
  margin-bottom: 0px;
  min-width: 280px;
}
.file-button-img-box {
  width: 36px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.file-button-img-DWI {
  background-position: 0px -1800px;
}
.file-button-img-EPM {
  background-position: 0px -1850px;
}
.file-button-img-SPM {
  background-position: 0px -1900px;
}
.file-button-img {
  width: 16px;
  height: 16px;
  background: url('/static/icons-small.png') no-repeat;
  zoom: 200%;
}
.el-card__body {
  padding: 10px !important;
}
</style>

